#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

int g_val = 0;
int main(){
  pid_t id = fork();
  while(1){

  if(id<0){
    perror("fork\n");
    return 0;
  }
  else if(id ==0){
    printf("child[%d]: %d g_val:%d : &g_val:%p\n",getpid(),getppid(),g_val,&g_val);
    g_val++;
  }else{
   printf("parent[%d]: %d g_val:%d : &g_val:%p\n",getpid(),getppid(),g_val,&g_val);
  }
 
  sleep(1);
  }

  return 0;
}
